package com.shlh.saas.service.canton.buyer.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shlh.saas.common.Desensitization;
import com.shlh.saas.entity.canton.buyer.*;
import com.shlh.saas.mapper.canton.buyer.*;
import com.shlh.saas.service.canton.buyer.CantonFairBuyerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 广交会采购商服务实现类
 */
@Service
@Slf4j
public class CantonFairBuyerServiceImpl implements CantonFairBuyerService {

    @Autowired
    private CantonFairBuyer125Mapper buyer125Mapper;

    @Autowired
    private CantonFairBuyer126Mapper buyer126Mapper;

    @Autowired
    private CantonFairBuyer127Mapper buyer127Mapper;

    @Autowired
    private CantonFairBuyer129Mapper buyer129Mapper;

    @Autowired
    private CantonFairBuyer130Mapper buyer130Mapper;

    @Autowired
    private CantonFairBuyer131Mapper buyer131Mapper;

    @Autowired
    private CantonFairBuyer132Mapper buyer132Mapper;

    @Autowired
    private CantonFairBuyer133Mapper buyer133Mapper;

    @Autowired
    private CantonFairBuyer134Mapper buyer134Mapper;

    @Autowired
    private CantonFairBuyer135Mapper buyer135Mapper;

    @Autowired
    private CantonFairBuyer136Mapper buyer136Mapper;

    @Autowired
    private CantonFairBuyer137Mapper buyer137Mapper;

    @Autowired
    private Desensitization desensitization;

    @Override
    public Page<CantonFairBuyer127> pageBuyer127(String companyName, String country, int pageNum, int pageSize) {
        Page<CantonFairBuyer127> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<CantonFairBuyer127> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(companyName)) {
            wrapper.like(CantonFairBuyer127::getCompanyName, companyName);
        }

        if (StringUtils.hasText(country)) {
            wrapper.eq(CantonFairBuyer127::getCountry, country);
        }

        return buyer127Mapper.selectPage(page, wrapper);
    }

    @Override
    public Page<CantonFairBuyer134> pageBuyer134(String companyName, String country, int pageNum, int pageSize) {
        Page<CantonFairBuyer134> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<CantonFairBuyer134> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(companyName)) {
            wrapper.like(CantonFairBuyer134::getCompanyName, companyName);
        }

        if (StringUtils.hasText(country)) {
            wrapper.eq(CantonFairBuyer134::getCountry, country);
        }

        return buyer134Mapper.selectPage(page, wrapper);
    }

    @Override
    public Page<CantonFairBuyer135> pageBuyer135(String companyName, String country, int pageNum, int pageSize) {
        Page<CantonFairBuyer135> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<CantonFairBuyer135> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(companyName)) {
            wrapper.like(CantonFairBuyer135::getCompanyName, companyName);
        }

        if (StringUtils.hasText(country)) {
            wrapper.eq(CantonFairBuyer135::getCountry, country);
        }

        return buyer135Mapper.selectPage(page, wrapper);
    }

    @Override
    public Page<CantonFairBuyer136> pageBuyer136(String companyName, String country, int pageNum, int pageSize) {
        Page<CantonFairBuyer136> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<CantonFairBuyer136> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(companyName)) {
            wrapper.like(CantonFairBuyer136::getCompanyName, companyName);
        }

        if (StringUtils.hasText(country)) {
            wrapper.eq(CantonFairBuyer136::getCountry, country);
        }

        return buyer136Mapper.selectPage(page, wrapper);
    }

    @Override
    public CantonFairBuyer127 getBuyer127ById(Integer id) {
        return buyer127Mapper.selectById(id);
    }

    @Override
    public CantonFairBuyer134 getBuyer134ById(Integer id) {
        return buyer134Mapper.selectById(id);
    }

    @Override
    public CantonFairBuyer135 getBuyer135ById(Integer id) {
        return buyer135Mapper.selectById(id);
    }

    @Override
    public CantonFairBuyer136 getBuyer136ById(Integer id) {
        return buyer136Mapper.selectById(id);
    }

    @Override
    public List<Object> findByCompanyName(String companyName) {
        if (!StringUtils.hasText(companyName)) {
            return new ArrayList<>();
        }

        List<Object> result = new ArrayList<>();

        // 查询第125届
        LambdaQueryWrapper<CantonFairBuyer125> wrapper125 = new LambdaQueryWrapper<>();
        wrapper125.like(CantonFairBuyer125::getCompanyName, companyName);
        List<CantonFairBuyer125> list125 = buyer125Mapper.selectList(wrapper125);
        result.addAll(list125);

        // 查询第126届
        LambdaQueryWrapper<CantonFairBuyer126> wrapper126 = new LambdaQueryWrapper<>();
        wrapper126.like(CantonFairBuyer126::getCompanyName, companyName);
        List<CantonFairBuyer126> list126 = buyer126Mapper.selectList(wrapper126);
        result.addAll(list126);

        // 查询第127届
        LambdaQueryWrapper<CantonFairBuyer127> wrapper127 = new LambdaQueryWrapper<>();
        wrapper127.like(CantonFairBuyer127::getCompanyName, companyName);
        List<CantonFairBuyer127> list127 = buyer127Mapper.selectList(wrapper127);
        result.addAll(list127);

        // 查询第129届
        LambdaQueryWrapper<CantonFairBuyer129> wrapper129 = new LambdaQueryWrapper<>();
        wrapper129.like(CantonFairBuyer129::getCompanyName, companyName);
        List<CantonFairBuyer129> list129 = buyer129Mapper.selectList(wrapper129);
        result.addAll(list129);

        // 查询第130届
        LambdaQueryWrapper<CantonFairBuyer130> wrapper130 = new LambdaQueryWrapper<>();
        wrapper130.like(CantonFairBuyer130::getCompanyName, companyName);
        List<CantonFairBuyer130> list130 = buyer130Mapper.selectList(wrapper130);
        result.addAll(list130);

        // 查询第131届
        LambdaQueryWrapper<CantonFairBuyer131> wrapper131 = new LambdaQueryWrapper<>();
        wrapper131.like(CantonFairBuyer131::getCompanyName, companyName);
        List<CantonFairBuyer131> list131 = buyer131Mapper.selectList(wrapper131);
        result.addAll(list131);

        // 查询第132届
        LambdaQueryWrapper<CantonFairBuyer132> wrapper132 = new LambdaQueryWrapper<>();
        wrapper132.like(CantonFairBuyer132::getCompanyName, companyName);
        List<CantonFairBuyer132> list132 = buyer132Mapper.selectList(wrapper132);
        result.addAll(list132);

        // 查询第133届
        LambdaQueryWrapper<CantonFairBuyer133> wrapper133 = new LambdaQueryWrapper<>();
        wrapper133.like(CantonFairBuyer133::getCompanyName, companyName);
        List<CantonFairBuyer133> list133 = buyer133Mapper.selectList(wrapper133);
        result.addAll(list133);

        // 查询第134届
        LambdaQueryWrapper<CantonFairBuyer134> wrapper134 = new LambdaQueryWrapper<>();
        wrapper134.like(CantonFairBuyer134::getCompanyName, companyName);
        List<CantonFairBuyer134> list134 = buyer134Mapper.selectList(wrapper134);
        result.addAll(list134);

        // 查询第135届
        LambdaQueryWrapper<CantonFairBuyer135> wrapper135 = new LambdaQueryWrapper<>();
        wrapper135.like(CantonFairBuyer135::getCompanyName, companyName);
        List<CantonFairBuyer135> list135 = buyer135Mapper.selectList(wrapper135);
        result.addAll(list135);

        // 查询第136届
        LambdaQueryWrapper<CantonFairBuyer136> wrapper136 = new LambdaQueryWrapper<>();
        wrapper136.like(CantonFairBuyer136::getCompanyName, companyName);
        List<CantonFairBuyer136> list136 = buyer136Mapper.selectList(wrapper136);
        result.addAll(list136);

        // 查询第137届
        LambdaQueryWrapper<CantonFairBuyer137> wrapper137 = new LambdaQueryWrapper<>();
        wrapper137.like(CantonFairBuyer137::getCompanyName, companyName);
        List<CantonFairBuyer137> list137 = buyer137Mapper.selectList(wrapper137);
        result.addAll(list137);

        return result;
    }

    @Override
    public List<BaseCantonFairBuyer> searchByKeywordInAllFields(String keyword, String productType, int offset, int limit,
                                                                String sessionInfo, String country, String hasContact) {
        log.info("在广交会采购商所有字段中搜索关键词: {}, 偏移量: {}, 限制数: {}, 届数: {}, 国家: {}",
                keyword, offset, limit, sessionInfo, country);
        List<BaseCantonFairBuyer> result = new ArrayList<>();

        try {
            // 如果指定了届数，只查询对应届数的表
            if (sessionInfo != null && !sessionInfo.isEmpty()) {
                String[] sessions = new String[]{""};
                if (sessionInfo.contains(",")) {
                    sessions = sessionInfo.split(",");
                } else {
                    sessions[0] = sessionInfo;
                }

                // 计算每个届数的总记录数
                Map<String, Long> sessionCounts = new HashMap<>();
                for (String session : sessions) {
                    switch (session) {
                        case "125":
                            sessionCounts.put(session, countBuyer125ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "126":
                            sessionCounts.put(session, countBuyer126ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "127":
                            sessionCounts.put(session, countBuyer127ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "129":
                            sessionCounts.put(session, countBuyer129ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "130":
                            sessionCounts.put(session, countBuyer130ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "131":
                            sessionCounts.put(session, countBuyer131ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "132":
                            sessionCounts.put(session, countBuyer132ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "133":
                            sessionCounts.put(session, countBuyer133ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "134":
                            sessionCounts.put(session, countBuyer134ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "135":
                            sessionCounts.put(session, countBuyer135ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "136":
                            sessionCounts.put(session, countBuyer136ByKeyword(keyword, productType, country, hasContact));
                            break;
                        case "137":
                            sessionCounts.put(session, countBuyer137ByKeyword(keyword, productType, country, hasContact));
                            break;
                        default:
                            log.warn("未知的广交会届数: {}", session);
                            break;
                    }
                }

                // 跨表分页变量
                int remaining = limit;
                int currentOffset = offset;

                // 根据不同的届数参数选择对应的表
                for (String session : sessions) {
                    if (remaining <= 0) break; // 结果集已满，提前终止

                    Long sessionCount = sessionCounts.get(session);
                    if (sessionCount == null || sessionCount <= 0) continue;

                    // 如果当前偏移量大于此届数数据量，跳过该届数
                    if (currentOffset >= sessionCount) {
                        currentOffset -= sessionCount;
                        continue;
                    }

                    // 计算当前届数需要查询的数量
                    int sessionLimit = (int) Math.min(remaining, sessionCount - currentOffset);

                    switch (session) {
                        case "125":
                            List<CantonFairBuyer125> list125 = searchBuyer125ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer125 buyer : list125) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "126":
                            List<CantonFairBuyer126> list126 = searchBuyer126ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer126 buyer : list126) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "127":
                            List<CantonFairBuyer127> list127 = searchBuyer127ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer127 buyer : list127) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "129":
                            List<CantonFairBuyer129> list129 = searchBuyer129ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer129 buyer : list129) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "130":
                            List<CantonFairBuyer130> list130 = searchBuyer130ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer130 buyer : list130) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "131":
                            List<CantonFairBuyer131> list131 = searchBuyer131ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer131 buyer : list131) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "132":
                            List<CantonFairBuyer132> list132 = searchBuyer132ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer132 buyer : list132) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "133":
                            List<CantonFairBuyer133> list133 = searchBuyer133ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer133 buyer : list133) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                baseBuyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "134":
                            List<CantonFairBuyer134> list134 = searchBuyer134ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer134 buyer : list134) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                buyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "135":
                            List<CantonFairBuyer135> list135 = searchBuyer135ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer135 buyer : list135) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                buyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "136":
                            List<CantonFairBuyer136> list136 = searchBuyer136ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer136 buyer : list136) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                buyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        case "137":
                            List<CantonFairBuyer137> list137 = searchBuyer137ByKeywordWithPage(
                                    keyword, productType, currentOffset, sessionLimit, country, hasContact);

                            for (CantonFairBuyer137 buyer : list137) {
                                BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                                desensitizationBuyer(baseBuyer);
                                buyer.setSessionsNum(session);
                                result.add(baseBuyer);
                                if (result.size() >= limit) {
                                    break;
                                }
                            }
                            break;
                        default:
                            log.warn("未知的广交会届数: {}", session);
                            break;
                    }

                    // 更新偏移量和剩余数量
                    if (result.size() >= limit) {
                        break; // 结果集已满，提前终止
                    }

                    // 更新剩余需要获取的记录数
                    remaining = limit - result.size();

                    // 后续届数从0开始（因为我们已经处理了当前偏移量）
                    currentOffset = 0;
                }
            } else {
                // 没有指定届数，按原逻辑查询所有表
                // 获取所有届次的数据总量，用于判断是否需要查询每个表
                long count125 = countBuyer125ByKeyword(keyword, productType, country, hasContact);
                long count126 = countBuyer126ByKeyword(keyword, productType, country, hasContact);
                long count127 = countBuyer127ByKeyword(keyword, productType, country, hasContact);
                long count129 = countBuyer129ByKeyword(keyword, productType, country, hasContact);
                long count130 = countBuyer130ByKeyword(keyword, productType, country, hasContact);
                long count131 = countBuyer131ByKeyword(keyword, productType, country, hasContact);
                long count132 = countBuyer132ByKeyword(keyword, productType, country, hasContact);
                long count133 = countBuyer133ByKeyword(keyword, productType, country, hasContact);
                long count134 = countBuyer134ByKeyword(keyword, productType, country, hasContact);
                long count135 = countBuyer135ByKeyword(keyword, productType, country, hasContact);
                long count136 = countBuyer136ByKeyword(keyword, productType, country, hasContact);
                long count137 = countBuyer137ByKeyword(keyword, productType, country, hasContact);

                // 计算每个表需要查询的数据量
                int remaining = limit;
                int currentOffset = offset;

                // 查询第125届数据
                if (currentOffset < count125) {
                    // 需要从第125届表中查询数据
                    int limit125 = (int) Math.min(remaining, count125 - currentOffset);
                    List<CantonFairBuyer125> list125 = searchBuyer125ByKeywordWithPage(
                            keyword, productType, currentOffset, limit125, country, hasContact);

                    for (CantonFairBuyer125 buyer : list125) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("125");
                        result.add(baseBuyer);
                    }

                    remaining -= list125.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第125届表
                    currentOffset -= (int) count125;
                }

                // 查询第126届数据
                if (currentOffset < count126) {
                    // 需要从第126届表中查询数据
                    int limit126 = (int) Math.min(remaining, count126 - currentOffset);
                    List<CantonFairBuyer126> list126 = searchBuyer126ByKeywordWithPage(
                            keyword, productType, currentOffset, limit126, country, hasContact);

                    for (CantonFairBuyer126 buyer : list126) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("126");
                        result.add(baseBuyer);
                    }

                    remaining -= list126.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第126届表
                    currentOffset -= (int) count126;
                }

                // 查询第127届数据
                if (currentOffset < count127) {
                    // 需要从第127届表中查询数据
                    int limit127 = (int) Math.min(remaining, count127 - currentOffset);
                    List<CantonFairBuyer127> list127 = searchBuyer127ByKeywordWithPage(
                            keyword, productType, currentOffset, limit127, country, hasContact);

                    for (CantonFairBuyer127 buyer : list127) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("127");
                        result.add(baseBuyer);
                    }

                    remaining -= list127.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第127届表
                    currentOffset -= (int) count127;
                }

                // 查询第129届数据
                if (currentOffset < count129) {
                    // 需要从第129届表中查询数据
                    int limit129 = (int) Math.min(remaining, count129 - currentOffset);
                    List<CantonFairBuyer129> list129 = searchBuyer129ByKeywordWithPage(
                            keyword, productType, currentOffset, limit129, country, hasContact);

                    for (CantonFairBuyer129 buyer : list129) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("129");
                        result.add(baseBuyer);
                    }

                    remaining -= list129.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第129届表
                    currentOffset -= (int) count129;
                }

                // 查询第130届数据
                if (currentOffset < count130) {
                    // 需要从第130届表中查询数据
                    int limit130 = (int) Math.min(remaining, count130 - currentOffset);
                    List<CantonFairBuyer130> list130 = searchBuyer130ByKeywordWithPage(
                            keyword, productType, currentOffset, limit130, country, hasContact);

                    for (CantonFairBuyer130 buyer : list130) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("130");
                        result.add(baseBuyer);
                    }

                    remaining -= list130.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第130届表
                    currentOffset -= (int) count130;
                }

                // 查询第131届数据
                if (currentOffset < count131) {
                    // 需要从第131届表中查询数据
                    int limit131 = (int) Math.min(remaining, count131 - currentOffset);
                    List<CantonFairBuyer131> list131 = searchBuyer131ByKeywordWithPage(
                            keyword, productType, currentOffset, limit131, country, hasContact);

                    for (CantonFairBuyer131 buyer : list131) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("131");
                        result.add(baseBuyer);
                    }

                    remaining -= list131.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第131届表
                    currentOffset -= (int) count131;
                }

                // 查询第132届数据
                if (currentOffset < count132) {
                    // 需要从第132届表中查询数据
                    int limit132 = (int) Math.min(remaining, count132 - currentOffset);
                    List<CantonFairBuyer132> list132 = searchBuyer132ByKeywordWithPage(
                            keyword, productType, currentOffset, limit132, country, hasContact);

                    for (CantonFairBuyer132 buyer : list132) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("132");
                        result.add(baseBuyer);
                    }

                    remaining -= list132.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第132届表
                    currentOffset -= (int) count132;
                }

                // 查询第133届数据
                if (currentOffset < count133) {
                    // 需要从第133届表中查询数据
                    int limit133 = (int) Math.min(remaining, count133 - currentOffset);
                    List<CantonFairBuyer133> list133 = searchBuyer133ByKeywordWithPage(
                            keyword, productType, currentOffset, limit133, country, hasContact);

                    for (CantonFairBuyer133 buyer : list133) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        baseBuyer.setSessionsNum("133");
                        result.add(baseBuyer);
                    }

                    remaining -= list133.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第133届表
                    currentOffset -= (int) count133;
                }

                // 查询第134届数据
                if (remaining > 0 && currentOffset < count134) {
                    // 需要从第134届表中查询数据
                    int limit134 = (int) Math.min(remaining, count134 - currentOffset);
                    List<CantonFairBuyer134> list134 = searchBuyer134ByKeywordWithPage(
                            keyword, productType, currentOffset, limit134, country, hasContact);

                    for (CantonFairBuyer134 buyer : list134) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        buyer.setSessionsNum("134");
                        result.add(baseBuyer);
                    }

                    remaining -= list134.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第134届表
                    currentOffset = currentOffset < count134 ? 0 : (int) (currentOffset - count134);
                }

                // 查询第135届数据
                if (remaining > 0 && currentOffset < count135) {
                    // 需要从第135届表中查询数据
                    int limit135 = (int) Math.min(remaining, count135 - currentOffset);
                    List<CantonFairBuyer135> list135 = searchBuyer135ByKeywordWithPage(
                            keyword, productType, currentOffset, limit135, country, hasContact);

                    for (CantonFairBuyer135 buyer : list135) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        buyer.setSessionsNum("135");
                        result.add(baseBuyer);
                    }

                    remaining -= list135.size();
                    currentOffset = 0; // 后续表从0开始
                } else {
                    // 跳过第135届表
                    currentOffset = currentOffset < count135 ? 0 : (int) (currentOffset - count135);
                }

                // 查询第136届数据
                if (remaining > 0 && currentOffset < count136) {
                    // 需要从第136届表中查询数据
                    int limit136 = (int) Math.min(remaining, count136 - currentOffset);
                    List<CantonFairBuyer136> list136 = searchBuyer136ByKeywordWithPage(
                            keyword, productType, currentOffset, limit136, country, hasContact);

                    for (CantonFairBuyer136 buyer : list136) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        buyer.setSessionsNum("136");
                        result.add(baseBuyer);
                    }
                } else {
                    // 跳过第136届表
                    currentOffset = currentOffset < count136 ? 0 : (int) (currentOffset - count136);
                }

                // 查询第137届数据
                if (remaining > 0 && currentOffset < count137) {
                    // 需要从第137届表中查询数据
                    int limit137 = (int) Math.min(remaining, count137 - currentOffset);
                    List<CantonFairBuyer137> list137 = searchBuyer137ByKeywordWithPage(
                            keyword, productType, currentOffset, limit137, country, hasContact);

                    for (CantonFairBuyer137 buyer : list137) {
                        BaseCantonFairBuyer baseBuyer = convertToBaseBuyer(buyer);
                        desensitizationBuyer(baseBuyer);
                        buyer.setSessionsNum("137");
                        result.add(baseBuyer);
                    }
                }
            }

            log.info("查询结果数量: {}", result.size());
        } catch (Exception e) {
            log.error("搜索广交会采购商数据失败", e);
        }

        return result;
    }

    private void desensitizationBuyer(BaseCantonFairBuyer baseBuyer) {
        if (baseBuyer.getPhone() != null) {
            String maskPhone = desensitization.maskPhone(baseBuyer.getPhone());
            baseBuyer.setPhone(maskPhone);
        }
        if (baseBuyer.getExtendedFields().get("mobile") != null) {
            String maskMobile = desensitization.maskPhone(baseBuyer.getExtendedFields().get("mobile"));
            baseBuyer.getExtendedFields().put("mobile", maskMobile);
        }
        if (baseBuyer.getEmail() != null) {
            String maskEmail = desensitization.maskEmail(baseBuyer.getEmail());
            baseBuyer.setEmail(maskEmail);
        }
        if (baseBuyer.getFax() != null) {
            String maskFax = desensitization.maskPhone(baseBuyer.getFax());
            baseBuyer.setFax(maskFax);
        }
        if (baseBuyer.getWebsite() != null) {
            String maskWebsite = desensitization.maskWebAddress(baseBuyer.getWebsite());
            baseBuyer.setWebsite(maskWebsite);
        }
    }

    @Override
    public long countByKeywordInAllFields(String keyword, String productType, String sessionInfo, String country, String hasContact) {
        log.info("统计广交会采购商关键词的记录数量，关键词: {}, 届数: {}, 国家: {}, 筛选方式: {}", keyword, sessionInfo, country, hasContact);

        try {
            // 如果指定了届数，只统计对应届数的表
            if (sessionInfo != null && !sessionInfo.isEmpty()) {
                String[] sessions;
                if (sessionInfo.contains(",")) {
                    sessions = sessionInfo.split(",");
                } else {
                    sessions = new String[]{sessionInfo}; // 优化数组初始化
                }

                long totalCount = 0L;  // 使用long基本类型替代Long包装类

                for (String session : sessions) {
                    switch (session.trim()) {  // 增加trim()防止空格干扰
                        case "125" -> {
                            log.info("统计第125届广交会...");
                            totalCount += countBuyer125ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "126" -> {
                            log.info("统计第126届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer126ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "127" -> {
                            log.info("统计第127届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer127ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "129" -> {
                            log.info("统计第129届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer129ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "130" -> {
                            log.info("统计第130届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer130ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "131" -> {
                            log.info("统计第131届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer131ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "132" -> {
                            log.info("统计第132届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer132ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "133" -> {
                            log.info("统计第133届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer133ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "134" -> {
                            log.info("统计第134届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer134ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "135" -> {
                            log.info("统计第135届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer135ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "136" -> {
                            log.info("统计第136届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer136ByKeyword(keyword, productType, country, hasContact);
                        }
                        case "137" -> {
                            log.info("统计第137届广交会采购商关键词匹配数量，关键词: {}, 国家: {}", keyword, country);
                            totalCount += countBuyer137ByKeyword(keyword, productType, country, hasContact);
                        }
                        default -> {
                            log.warn("未知的广交会届数: {}", session);
                            // 继续处理后续届数
                        }
                    }
                }
                return totalCount;
            }

            // 没有指定届数，统计所有表
            long count125 = countBuyer125ByKeyword(keyword, productType, country, hasContact);
            long count126 = countBuyer126ByKeyword(keyword, productType, country, hasContact);
            long count127 = countBuyer127ByKeyword(keyword, productType, country, hasContact);
            long count129 = countBuyer129ByKeyword(keyword, productType, country, hasContact);
            long count130 = countBuyer130ByKeyword(keyword, productType, country, hasContact);
            long count131 = countBuyer131ByKeyword(keyword, productType, country, hasContact);
            long count132 = countBuyer132ByKeyword(keyword, productType, country, hasContact);
            long count133 = countBuyer133ByKeyword(keyword, productType, country, hasContact);
            long count134 = countBuyer134ByKeyword(keyword, productType, country, hasContact);
            long count135 = countBuyer135ByKeyword(keyword, productType, country, hasContact);
            long count136 = countBuyer136ByKeyword(keyword, productType, country, hasContact);
            long count137 = countBuyer137ByKeyword(keyword, productType, country, hasContact);

            long total = count125 + count126 + count127 + count129 + count130 + count131 + count132 + count133 + count134 + count135 + count136 + count137;
            log.info("广交会采购商总数: {}, 125届: {}, 126届: {}, 127届: {}, 129届: {}, 130届: {}, 131届: {}, 132届: {}, 133届: {}, 134届: {}, 135届: {}, 136届: {}, 137届: {}",
                    total, count125, count126, count127, count129, count130, count131, count132, count133, count134, count135, count136, count137);

            return total;
        } catch (Exception e) {
            log.error("统计广交会采购商数据数量失败", e);
            return 0;
        }
    }


    /**
     * 获取采购商完整的联系信息
     */
    @Override
    public String getFullContactInfo(Long purchaserId, Integer sessionNumber, String fieldName) {
        if (purchaserId == null || sessionNumber == null || !StringUtils.hasText(fieldName)) {
            throw new IllegalArgumentException("参数不完整");
        }

        try {
            // 根据届数选择对应的Mapper
            switch (sessionNumber) {
                case 125:
                    CantonFairBuyer125 buyer125 = buyer125Mapper.selectById(purchaserId);
                    if (buyer125 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer125, fieldName);
                case 126:
                    CantonFairBuyer126 buyer126 = buyer126Mapper.selectById(purchaserId);
                    if (buyer126 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer126, fieldName);
                case 127:
                    CantonFairBuyer127 buyer127 = buyer127Mapper.selectById(purchaserId);
                    if (buyer127 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer127, fieldName);
                case 129:
                    CantonFairBuyer129 buyer129 = buyer129Mapper.selectById(purchaserId);
                    if (buyer129 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer129, fieldName);
                case 130:
                    CantonFairBuyer130 buyer130 = buyer130Mapper.selectById(purchaserId);
                    if (buyer130 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer130, fieldName);
                case 131:
                    CantonFairBuyer131 buyer131 = buyer131Mapper.selectById(purchaserId);
                    if (buyer131 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer131, fieldName);
                case 132:
                    CantonFairBuyer132 buyer132 = buyer132Mapper.selectById(purchaserId);
                    if (buyer132 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer132, fieldName);
                case 133:
                    CantonFairBuyer133 buyer133 = buyer133Mapper.selectById(purchaserId);
                    if (buyer133 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer133, fieldName);
                case 134:
                    CantonFairBuyer134 buyer134 = buyer134Mapper.selectById(purchaserId);
                    if (buyer134 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer134, fieldName);
                case 135:
                    CantonFairBuyer135 buyer135 = buyer135Mapper.selectById(purchaserId);
                    if (buyer135 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer135, fieldName);
                case 136:
                    CantonFairBuyer136 buyer136 = buyer136Mapper.selectById(purchaserId);
                    if (buyer136 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer136, fieldName);
                case 137:
                    CantonFairBuyer137 buyer137 = buyer137Mapper.selectById(purchaserId);
                    if (buyer137 == null) {
                        throw new IllegalArgumentException("未找到对应的采购商信息");
                    }
                    return getFieldValueByName(buyer137, fieldName);
                default:
                    throw new IllegalArgumentException("不支持的广交会届数：" + sessionNumber);
            }
        } catch (Exception e) {
            log.error("获取采购商完整联系信息失败，purchaserId: {}, sessionNumber: {}, fieldName: {}", purchaserId, sessionNumber, fieldName, e);
            throw new RuntimeException("获取采购商完整联系信息失败: " + e.getMessage());
        }
    }

    /**
     * 根据字段名称获取对象中的字段值
     *
     * @param obj       对象
     * @param fieldName 字段名称
     * @return 字段值
     */
    private String getFieldValueByName(Object obj, String fieldName) {
        try {
            // 统一转换字段名称格式（驼峰式）
            String formattedFieldName = formatFieldNameToCamelCase(fieldName);

            // 获取所有字段，包括父类的字段
            List<Field> fields = getAllFields(obj.getClass());

            for (Field field : fields) {
                field.setAccessible(true);
                if (field.getName().equalsIgnoreCase(formattedFieldName)) {
                    Object value = field.get(obj);
                    if (value == null) {
                        return "";
                    }

                    String strValue = value.toString();

                    // 根据字段类型应用不同的脱敏处理
                    if (formattedFieldName.equalsIgnoreCase("email")) {
                        return strValue; // 返回完整邮箱
                    } else if (formattedFieldName.equalsIgnoreCase("telephone")) {
                        return strValue; // 返回完整电话号码
                    } else if (formattedFieldName.equalsIgnoreCase("mobile")) {
                        return strValue; // 返回完整手机号码
                    } else if (formattedFieldName.equalsIgnoreCase("fax")) {
                        return strValue; // 返回完整传真号码
                    } else if (formattedFieldName.equalsIgnoreCase("website")) {
                        return strValue; // 返回完整网址
                    } else {
                        return strValue;
                    }
                }
            }
            throw new IllegalArgumentException("未找到字段：" + fieldName);
        } catch (Exception e) {
            log.error("获取字段值失败，fieldName: {}", fieldName, e);
            throw new RuntimeException("获取字段值失败: " + e.getMessage());
        }
    }

    /**
     * 获取类的所有字段，包括父类字段
     *
     * @param clazz 类
     * @return 所有字段列表
     */
    private List<Field> getAllFields(Class<?> clazz) {
        List<Field> fields = new ArrayList<>();

        while (clazz != null && clazz != Object.class) {
            fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
            clazz = clazz.getSuperclass();
        }

        return fields;
    }

    /**
     * 将字段名格式化为驼峰式
     *
     * @param fieldName 字段名称
     * @return 驼峰式字段名
     */
    private String formatFieldNameToCamelCase(String fieldName) {
        // 常见的映射关系
        Map<String, String> fieldMapping = new HashMap<>();
        fieldMapping.put("email", "email");
        fieldMapping.put("phone", "phone");
        fieldMapping.put("telephone", "telephone");
        fieldMapping.put("mobilePhone", "mobile");
        fieldMapping.put("fax", "fax");
        fieldMapping.put("website", "website");
        fieldMapping.put("address", "address");
        fieldMapping.put("companyName", "companyName");

        if (fieldMapping.containsKey(fieldName)) {
            return fieldMapping.get(fieldName);
        }

        // 如果没有预定义映射，则转换为驼峰式
        StringBuilder result = new StringBuilder();
        boolean capitalizeNext = false;

        for (char c : fieldName.toCharArray()) {
            if (c == '_' || c == '-' || c == ' ') {
                capitalizeNext = true;
            } else {
                if (capitalizeNext) {
                    result.append(Character.toUpperCase(c));
                    capitalizeNext = false;
                } else {
                    result.append(Character.toLowerCase(c));
                }
            }
        }

        return result.toString();
    }

    /**
     * 按关键词搜索第125届广交会采购商（带分页）
     */
    private List<CantonFairBuyer125> searchBuyer125ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer125> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer125::getCompanyName, keyword)
                    .or().like(CantonFairBuyer125::getCountry, keyword)
                    .or().like(CantonFairBuyer125::getContactPerson, keyword)
                    .or().like(CantonFairBuyer125::getPhone, keyword)
                    .or().like(CantonFairBuyer125::getEmail, keyword)
                    .or().like(CantonFairBuyer125::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer125::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer125::getDemandGoods, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer125::getPhone)
                        .ne(CantonFairBuyer125::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer125::getEmail)
                        .ne(CantonFairBuyer125::getEmail, "");
            }
//            if (hasContact.contains("mobile")) {
//                wrapper.isNotNull(CantonFairBuyer125::getMobile)
//                        .ne(CantonFairBuyer125::getMobile, "");
//            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer125::getFax)
                        .ne(CantonFairBuyer125::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer125::getWebsite)
                        .ne(CantonFairBuyer125::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer125> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer125> resultPage = buyer125Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 按关键词搜索第126届广交会采购商（带分页）
     */
    private List<CantonFairBuyer126> searchBuyer126ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer126> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer126::getCompanyName, keyword)
                    .or().like(CantonFairBuyer126::getCountry, keyword)
                    .or().like(CantonFairBuyer126::getContactPerson, keyword)
                    .or().like(CantonFairBuyer126::getPhone, keyword)
                    .or().like(CantonFairBuyer126::getEmail, keyword)
                    .or().like(CantonFairBuyer126::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer126::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer126::getDemandGoods, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer126::getPhone)
                        .ne(CantonFairBuyer126::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer126::getEmail)
                        .ne(CantonFairBuyer126::getEmail, "");
            }
//            if (hasContact.contains("phone")) {
//                wrapper.isNotNull(CantonFairBuyer126::getTelephone)
//                        .ne(CantonFairBuyer126::getTelephone, "");
//            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer126::getFax)
                        .ne(CantonFairBuyer126::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer126::getWebsite)
                        .ne(CantonFairBuyer126::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer126> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer126> resultPage = buyer126Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 按关键词搜索第127届广交会采购商（带分页）
     */
    private List<CantonFairBuyer127> searchBuyer127ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer127> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer127::getCompanyName, keyword)
                    .or().like(CantonFairBuyer127::getCountry, keyword)
                    .or().like(CantonFairBuyer127::getContactPerson, keyword)
                    .or().like(CantonFairBuyer127::getPhone, keyword)
                    .or().like(CantonFairBuyer127::getEmail, keyword)
                    .or().like(CantonFairBuyer127::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer127::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer127::getDemandGoods, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer127::getPhone)
                        .ne(CantonFairBuyer127::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer127::getEmail)
                        .ne(CantonFairBuyer127::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer127::getFax)
                        .ne(CantonFairBuyer127::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer127::getWebsite)
                        .ne(CantonFairBuyer127::getWebsite, "");
            }
        }


        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer127> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer127> resultPage = buyer127Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 按关键词搜索第129届广交会采购商（带分页）
     */
    private List<CantonFairBuyer129> searchBuyer129ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer129> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer129::getCompanyName, keyword)
                    .or().like(CantonFairBuyer129::getCountry, keyword)
                    .or().like(CantonFairBuyer129::getContactPerson, keyword)
                    .or().like(CantonFairBuyer129::getPhone, keyword)
                    .or().like(CantonFairBuyer129::getEmail, keyword)
                    .or().like(CantonFairBuyer129::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer129::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer129::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer129::getPhone)
                        .ne(CantonFairBuyer129::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer129::getEmail)
                        .ne(CantonFairBuyer129::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer129::getFax)
                        .ne(CantonFairBuyer129::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer129::getWebsite)
                        .ne(CantonFairBuyer129::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer129> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer129> resultPage = buyer129Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }


    /**
     * 按关键词搜索第130届广交会采购商（带分页）
     */
    private List<CantonFairBuyer130> searchBuyer130ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer130> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer130::getCompanyName, keyword)
                    .or().like(CantonFairBuyer130::getCountry, keyword)
                    .or().like(CantonFairBuyer130::getContactPerson, keyword)
                    .or().like(CantonFairBuyer130::getPhone, keyword)
                    .or().like(CantonFairBuyer130::getEmail, keyword)
                    .or().like(CantonFairBuyer130::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer130::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer130::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer130::getPhone)
                        .ne(CantonFairBuyer130::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer130::getEmail)
                        .ne(CantonFairBuyer130::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer130::getFax)
                        .ne(CantonFairBuyer130::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer130::getWebsite)
                        .ne(CantonFairBuyer130::getWebsite, "");
            }
        }


        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer130> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer130> resultPage = buyer130Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 按关键词搜索第131届广交会采购商（带分页）
     */
    private List<CantonFairBuyer131> searchBuyer131ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer131> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer131::getCompanyName, keyword)
                    .or().like(CantonFairBuyer131::getCountry, keyword)
                    .or().like(CantonFairBuyer131::getContactPerson, keyword)
                    .or().like(CantonFairBuyer131::getPhone, keyword)
                    .or().like(CantonFairBuyer131::getEmail, keyword)
                    .or().like(CantonFairBuyer131::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer131::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer131::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer131::getPhone)
                        .ne(CantonFairBuyer131::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer131::getEmail)
                        .ne(CantonFairBuyer131::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer131::getFax)
                        .ne(CantonFairBuyer131::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer131::getWebsite)
                        .ne(CantonFairBuyer131::getWebsite, "");
            }
        }


        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer131> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer131> resultPage = buyer131Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 按关键词搜索第132届广交会采购商（带分页）
     */
    private List<CantonFairBuyer132> searchBuyer132ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer132> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer132::getCompanyName, keyword)
                    .or().like(CantonFairBuyer132::getCountry, keyword)
                    .or().like(CantonFairBuyer132::getContactPerson, keyword)
                    .or().like(CantonFairBuyer132::getPhone, keyword)
                    .or().like(CantonFairBuyer132::getEmail, keyword)
                    .or().like(CantonFairBuyer132::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer132::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer132::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer132::getPhone)
                        .ne(CantonFairBuyer132::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer132::getEmail)
                        .ne(CantonFairBuyer132::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer132::getFax)
                        .ne(CantonFairBuyer132::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer132::getWebsite)
                        .ne(CantonFairBuyer132::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer132> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer132> resultPage = buyer132Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 按关键词搜索第133届广交会采购商（带分页）
     */
    private List<CantonFairBuyer133> searchBuyer133ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer133> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer133::getCompanyName, keyword)
                    .or().like(CantonFairBuyer133::getCountry, keyword)
                    .or().like(CantonFairBuyer133::getContactPerson, keyword)
                    .or().like(CantonFairBuyer133::getPhone, keyword)
                    .or().like(CantonFairBuyer133::getEmail, keyword)
                    .or().like(CantonFairBuyer133::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countrise = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countrise) {
                    w.or().like(CantonFairBuyer133::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer133::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer133::getPhone)
                        .ne(CantonFairBuyer133::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer133::getEmail)
                        .ne(CantonFairBuyer133::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer133::getFax)
                        .ne(CantonFairBuyer133::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer133::getWebsite)
                        .ne(CantonFairBuyer133::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer133> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer133> resultPage = buyer133Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }


    /**
     * 按关键词搜索第134届广交会采购商（带分页）
     */
    private List<CantonFairBuyer134> searchBuyer134ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer134> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer134::getCompanyName, keyword)
                    .or().like(CantonFairBuyer134::getCountry, keyword)
                    .or().like(CantonFairBuyer134::getContactPerson, keyword)
                    .or().like(CantonFairBuyer134::getPhone, keyword)
                    .or().like(CantonFairBuyer134::getEmail, keyword)
                    .or().like(CantonFairBuyer134::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer134::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer134::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer134::getPhone)
                        .ne(CantonFairBuyer134::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer134::getEmail)
                        .ne(CantonFairBuyer134::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer134::getFax)
                        .ne(CantonFairBuyer134::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer134::getWebsite)
                        .ne(CantonFairBuyer134::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer134> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer134> resultPage = buyer134Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 统计第125届广交会采购商关键词匹配数量
     */
    private long countBuyer125ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer125> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer125::getCompanyName, keyword)
                    .or().like(CantonFairBuyer125::getCountry, keyword)
                    .or().like(CantonFairBuyer125::getContactPerson, keyword)
                    .or().like(CantonFairBuyer125::getPhone, keyword)
                    .or().like(CantonFairBuyer125::getEmail, keyword)
                    .or().like(CantonFairBuyer125::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer125::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer125::getDemandGoods, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer125::getPhone)
                        .ne(CantonFairBuyer125::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer125::getEmail)
                        .ne(CantonFairBuyer125::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer125::getFax)
                        .ne(CantonFairBuyer125::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer125::getWebsite)
                        .ne(CantonFairBuyer125::getWebsite, "");
            }
        }

        return buyer125Mapper.selectCount(wrapper);
    }

    /**
     * 统计第126届广交会采购商关键词匹配数量
     */
    private long countBuyer126ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer126> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer126::getCompanyName, keyword)
                    .or().like(CantonFairBuyer126::getCountry, keyword)
                    .or().like(CantonFairBuyer126::getContactPerson, keyword)
                    .or().like(CantonFairBuyer126::getPhone, keyword)
                    .or().like(CantonFairBuyer126::getEmail, keyword)
                    .or().like(CantonFairBuyer126::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer126::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer126::getDemandGoods, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer126::getPhone)
                        .ne(CantonFairBuyer126::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer126::getEmail)
                        .ne(CantonFairBuyer126::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer126::getFax)
                        .ne(CantonFairBuyer126::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer126::getWebsite)
                        .ne(CantonFairBuyer126::getWebsite, "");
            }
        }

        return buyer126Mapper.selectCount(wrapper);
    }

    /**
     * 统计第127届广交会采购商关键词匹配数量
     */
    private long countBuyer127ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer127> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer127::getCompanyName, keyword)
                    .or().like(CantonFairBuyer127::getCountry, keyword)
                    .or().like(CantonFairBuyer127::getContactPerson, keyword)
                    .or().like(CantonFairBuyer127::getPhone, keyword)
                    .or().like(CantonFairBuyer127::getEmail, keyword)
                    .or().like(CantonFairBuyer127::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer127::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer127::getDemandGoods, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer127::getPhone)
                        .ne(CantonFairBuyer127::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer127::getEmail)
                        .ne(CantonFairBuyer127::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer127::getFax)
                        .ne(CantonFairBuyer127::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer127::getWebsite)
                        .ne(CantonFairBuyer127::getWebsite, "");
            }
        }

        return buyer127Mapper.selectCount(wrapper);
    }

    /**
     * 统计第129届广交会采购商关键词匹配数量
     */
    private long countBuyer129ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer129> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer129::getCompanyName, keyword)
                    .or().like(CantonFairBuyer129::getCountry, keyword)
                    .or().like(CantonFairBuyer129::getContactPerson, keyword)
                    .or().like(CantonFairBuyer129::getPhone, keyword)
                    .or().like(CantonFairBuyer129::getEmail, keyword)
                    .or().like(CantonFairBuyer129::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer129::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer129::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer129::getPhone)
                        .ne(CantonFairBuyer129::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer129::getEmail)
                        .ne(CantonFairBuyer129::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer129::getFax)
                        .ne(CantonFairBuyer129::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer129::getWebsite)
                        .ne(CantonFairBuyer129::getWebsite, "");
            }
        }

        return buyer129Mapper.selectCount(wrapper);
    }

    /**
     * 统计第130届广交会采购商关键词匹配数量
     */
    private long countBuyer130ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer130> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer130::getCompanyName, keyword)
                    .or().like(CantonFairBuyer130::getCountry, keyword)
                    .or().like(CantonFairBuyer130::getContactPerson, keyword)
                    .or().like(CantonFairBuyer130::getPhone, keyword)
                    .or().like(CantonFairBuyer130::getEmail, keyword)
                    .or().like(CantonFairBuyer130::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer130::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer130::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer130::getPhone)
                        .ne(CantonFairBuyer130::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer130::getEmail)
                        .ne(CantonFairBuyer130::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer130::getFax)
                        .ne(CantonFairBuyer130::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer130::getWebsite)
                        .ne(CantonFairBuyer130::getWebsite, "");
            }
        }

        return buyer130Mapper.selectCount(wrapper);
    }

    /**
     * 统计第131届广交会采购商关键词匹配数量
     */
    private long countBuyer131ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer131> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer131::getCompanyName, keyword)
                    .or().like(CantonFairBuyer131::getCountry, keyword)
                    .or().like(CantonFairBuyer131::getContactPerson, keyword)
                    .or().like(CantonFairBuyer131::getPhone, keyword)
                    .or().like(CantonFairBuyer131::getEmail, keyword)
                    .or().like(CantonFairBuyer131::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer131::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer131::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer131::getPhone)
                        .ne(CantonFairBuyer131::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer131::getEmail)
                        .ne(CantonFairBuyer131::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer131::getFax)
                        .ne(CantonFairBuyer131::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer131::getWebsite)
                        .ne(CantonFairBuyer131::getWebsite, "");
            }
        }

        return buyer131Mapper.selectCount(wrapper);
    }

    /**
     * 统计第132届广交会采购商关键词匹配数量
     */
    private long countBuyer132ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer132> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer132::getCompanyName, keyword)
                    .or().like(CantonFairBuyer132::getCountry, keyword)
                    .or().like(CantonFairBuyer132::getContactPerson, keyword)
                    .or().like(CantonFairBuyer132::getPhone, keyword)
                    .or().like(CantonFairBuyer132::getEmail, keyword)
                    .or().like(CantonFairBuyer132::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer132::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer132::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer132::getPhone)
                        .ne(CantonFairBuyer132::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer132::getEmail)
                        .ne(CantonFairBuyer132::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer132::getFax)
                        .ne(CantonFairBuyer132::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer132::getWebsite)
                        .ne(CantonFairBuyer132::getWebsite, "");
            }
        }

        return buyer132Mapper.selectCount(wrapper);
    }


    /**
     * 统计第133届广交会采购商关键词匹配数量
     */
    private long countBuyer133ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer133> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer133::getCompanyName, keyword)
                    .or().like(CantonFairBuyer133::getCountry, keyword)
                    .or().like(CantonFairBuyer133::getContactPerson, keyword)
                    .or().like(CantonFairBuyer133::getPhone, keyword)
                    .or().like(CantonFairBuyer133::getEmail, keyword)
                    .or().like(CantonFairBuyer133::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer133::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer133::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer133::getPhone)
                        .ne(CantonFairBuyer133::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer133::getEmail)
                        .ne(CantonFairBuyer133::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer133::getFax)
                        .ne(CantonFairBuyer133::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer133::getWebsite)
                        .ne(CantonFairBuyer133::getWebsite, "");
            }
        }

        return buyer133Mapper.selectCount(wrapper);
    }

    /**
     * 统计第134届广交会采购商关键词匹配数量
     */
    private long countBuyer134ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer134> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer134::getCompanyName, keyword)
                    .or().like(CantonFairBuyer134::getCountry, keyword)
                    .or().like(CantonFairBuyer134::getContactPerson, keyword)
                    .or().like(CantonFairBuyer134::getPhone, keyword)
                    .or().like(CantonFairBuyer134::getEmail, keyword)
                    .or().like(CantonFairBuyer134::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer134::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer134::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer134::getPhone)
                        .ne(CantonFairBuyer134::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer134::getEmail)
                        .ne(CantonFairBuyer134::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer134::getFax)
                        .ne(CantonFairBuyer134::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer134::getWebsite)
                        .ne(CantonFairBuyer134::getWebsite, "");
            }
        }

        return buyer134Mapper.selectCount(wrapper);
    }

    /**
     * 按关键词搜索第135届广交会采购商（带分页）
     */
    private List<CantonFairBuyer135> searchBuyer135ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer135> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer135::getCompanyName, keyword)
                    .or().like(CantonFairBuyer135::getCountry, keyword)
                    .or().like(CantonFairBuyer135::getContactPerson, keyword)
                    .or().like(CantonFairBuyer135::getPhone, keyword)
                    .or().like(CantonFairBuyer135::getEmail, keyword)
                    .or().like(CantonFairBuyer135::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer135::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer135::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer135::getPhone)
                        .ne(CantonFairBuyer135::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer135::getEmail)
                        .ne(CantonFairBuyer135::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer135::getFax)
                        .ne(CantonFairBuyer135::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer135::getWebsite)
                        .ne(CantonFairBuyer135::getWebsite, "");
            }
        }


        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer135> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer135> resultPage = buyer135Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 按关键词搜索第137届广交会采购商（带分页）
     */
    private List<CantonFairBuyer137> searchBuyer137ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer137> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer137::getCompanyName, keyword)
                    .or().like(CantonFairBuyer137::getCountry, keyword)
                    .or().like(CantonFairBuyer137::getContactPerson, keyword)
                    .or().like(CantonFairBuyer137::getPhone, keyword)
                    .or().like(CantonFairBuyer137::getEmail, keyword)
                    .or().like(CantonFairBuyer137::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer137::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer137::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer137::getPhone)
                        .ne(CantonFairBuyer137::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer137::getEmail)
                        .ne(CantonFairBuyer137::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer137::getFax)
                        .ne(CantonFairBuyer137::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer137::getWebsite)
                        .ne(CantonFairBuyer137::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer137> page = new Page<>(pageNum, limit);
        Page<CantonFairBuyer137> resultPage = buyer137Mapper.selectPage(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 统计第135届广交会采购商关键词匹配数量
     */
    private long countBuyer135ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer135> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer135::getCompanyName, keyword)
                    .or().like(CantonFairBuyer135::getCountry, keyword)
                    .or().like(CantonFairBuyer135::getContactPerson, keyword)
                    .or().like(CantonFairBuyer135::getPhone, keyword)
                    .or().like(CantonFairBuyer135::getEmail, keyword)
                    .or().like(CantonFairBuyer135::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            wrapper.like(CantonFairBuyer135::getCountry, country);
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer135::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer135::getPhone)
                        .ne(CantonFairBuyer135::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer135::getEmail)
                        .ne(CantonFairBuyer135::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer135::getFax)
                        .ne(CantonFairBuyer135::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer135::getWebsite)
                        .ne(CantonFairBuyer135::getWebsite, "");
            }
        }

        return buyer135Mapper.selectCount(wrapper);
    }

    /**
     * 按关键词搜索第136届广交会采购商（带分页）
     */
    private List<CantonFairBuyer136> searchBuyer136ByKeywordWithPage(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer136> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer136::getCompanyName, keyword)
                    .or().like(CantonFairBuyer136::getCountry, keyword)
                    .or().like(CantonFairBuyer136::getContactPerson, keyword)
                    .or().like(CantonFairBuyer136::getPhone, keyword)
                    .or().like(CantonFairBuyer136::getEmail, keyword)
                    .or().like(CantonFairBuyer136::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            List<String> countries = Arrays.asList(country.split(","));
            wrapper.and(w -> {
                for (String c : countries) {
                    w.or().like(CantonFairBuyer136::getCountry, c.trim());
                }
            });
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer136::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer136::getPhone)
                        .ne(CantonFairBuyer136::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer136::getEmail)
                        .ne(CantonFairBuyer136::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer136::getFax)
                        .ne(CantonFairBuyer136::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer136::getWebsite)
                        .ne(CantonFairBuyer136::getWebsite, "");
            }
        }

        // 计算页码（从1开始）和每页大小
        int pageNum = limit > 0 ? offset / limit + 1 : 1;
        Page<CantonFairBuyer136> page = new Page<>(pageNum, limit);
        // 使用自定义查询方法，避免 MyBatis 自动生成包含不存在字段的 SQL
        Page<CantonFairBuyer136> resultPage = buyer136Mapper.selectPageWithCustomSql(page, wrapper);
        return resultPage.getRecords();
    }

    /**
     * 统计第136届广交会采购商关键词匹配数量
     */
    private long countBuyer136ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer136> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer136::getCompanyName, keyword)
                    .or().like(CantonFairBuyer136::getCountry, keyword)
                    .or().like(CantonFairBuyer136::getContactPerson, keyword)
                    .or().like(CantonFairBuyer136::getPhone, keyword)
                    .or().like(CantonFairBuyer136::getEmail, keyword)
                    .or().like(CantonFairBuyer136::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            wrapper.like(CantonFairBuyer136::getCountry, country);
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer136::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer136::getPhone)
                        .ne(CantonFairBuyer136::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer136::getEmail)
                        .ne(CantonFairBuyer136::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer136::getFax)
                        .ne(CantonFairBuyer136::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer136::getWebsite)
                        .ne(CantonFairBuyer136::getWebsite, "");
            }
        }

        return buyer136Mapper.selectCount(wrapper);
    }

    /**
     * 统计第136届广交会采购商关键词匹配数量
     */
    private long countBuyer137ByKeyword(String keyword, String productType, String country, String hasContact) {
        LambdaQueryWrapper<CantonFairBuyer137> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.hasText(keyword)) {
            wrapper.and(w -> w
                    .like(CantonFairBuyer137::getCompanyName, keyword)
                    .or().like(CantonFairBuyer137::getCountry, keyword)
                    .or().like(CantonFairBuyer137::getContactPerson, keyword)
                    .or().like(CantonFairBuyer137::getPhone, keyword)
                    .or().like(CantonFairBuyer137::getEmail, keyword)
                    .or().like(CantonFairBuyer137::getAddress, keyword)
            );
        }

        // 添加国家筛选
        if (StringUtils.hasText(country)) {
            wrapper.like(CantonFairBuyer137::getCountry, country);
        }

        // 添加产品筛选
        if (StringUtils.hasText(productType)) {
            wrapper.like(CantonFairBuyer137::getProductCategory, productType);
        }

        // 添加联系方式筛选
        if (StringUtils.hasText(hasContact)) {
            if (hasContact.contains("phone")) {
                wrapper.isNotNull(CantonFairBuyer137::getPhone)
                        .ne(CantonFairBuyer137::getPhone, "");
            }
            if (hasContact.contains("email")) {
                wrapper.isNotNull(CantonFairBuyer137::getEmail)
                        .ne(CantonFairBuyer137::getEmail, "");
            }
            if (hasContact.contains("fax")) {
                wrapper.isNotNull(CantonFairBuyer137::getFax)
                        .ne(CantonFairBuyer137::getFax, "");
            }
            if (hasContact.contains("website")) {
                wrapper.isNotNull(CantonFairBuyer137::getWebsite)
                        .ne(CantonFairBuyer137::getWebsite, "");
            }
        }

        return buyer137Mapper.selectCount(wrapper);
    }

    /**
     * 将CantonFairBuyer125转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer125 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第125届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getDemandGoods());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        baseBuyer.getExtendedFields().put("purchaseList", buyer.getPurchaseList());
        baseBuyer.getExtendedFields().put("demandInfo", buyer.getDemandInfo());
        baseBuyer.getExtendedFields().put("mobile", buyer.getMobile());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer126转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer126 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第126届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getDemandGoods());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        baseBuyer.getExtendedFields().put("purchaseList", buyer.getPurchaseList());
        baseBuyer.getExtendedFields().put("demandInfo", buyer.getDemandInfo());

        return baseBuyer;
    }


    /**
     * 将CantonFairBuyer127转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer127 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第127届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getDemandGoods());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        baseBuyer.getExtendedFields().put("purchaseList", buyer.getPurchaseList());
        baseBuyer.getExtendedFields().put("demandInfo", buyer.getDemandInfo());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer129转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer129 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第129届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer130转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer130 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第130届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer131转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer131 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第131届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer132转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer132 buyer) {
        BaseCantonFairBuyer baseBuyer = new CantonFairBuyer132();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第132届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer133转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer133 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        // 添加扩展信息
        baseBuyer.getExtendedFields().put("sessionInfo", "第133届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer134转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer134 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());

        baseBuyer.getExtendedFields().put("sessionInfo", "第134届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer135转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer135 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        baseBuyer.setPhone(buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());

        baseBuyer.getExtendedFields().put("sessionInfo", "第135届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer136转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer136 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        baseBuyer.setPhone(buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setSessionsNum(buyer.getSessionsNum());
        baseBuyer.setWebsite(buyer.getWebsite());

        baseBuyer.getExtendedFields().put("sessionInfo", "第136届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());

        return baseBuyer;
    }

    /**
     * 将CantonFairBuyer137转换为BaseCantonFairBuyer
     */
    private BaseCantonFairBuyer convertToBaseBuyer(CantonFairBuyer137 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        if (buyer.getTelephone() != null) {
            baseBuyer.setPhone(buyer.getTelephone());
        } else {
            baseBuyer.setPhone(buyer.getPhone());
        }
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setAddress(buyer.getAddress());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setSessionsNum(buyer.getSessionsNum());
        baseBuyer.setWebsite(buyer.getWebsite());

        baseBuyer.getExtendedFields().put("sessionInfo", "第137届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());

        return baseBuyer;
    }

    @Override
    public List<BaseCantonFairBuyer> searchByKeywordInAllFieldsForExport(String keyword, String productType, int offset, int limit,
                                                                         String sessionInfo, String country, String hasContact) {
        log.info("导出专用：在广交会采购商所有字段中搜索关键词: {}, 偏移量: {}, 限制数: {}, 届数: {}, 国家: {}, 联系方式: {}",
                keyword, offset, limit, sessionInfo, country, hasContact);
        List<BaseCantonFairBuyer> result = new ArrayList<>();

        try {
            if (StringUtils.hasText(sessionInfo)) {
                // 如果指定了届数，只查询对应届数的表
                String[] sessions = sessionInfo.split(",");

                for (String session : sessions) {
                    switch (session.trim()) {
                        case "125":
                            long count125 = countBuyer125ByKeyword(keyword, productType, country, hasContact);
                            if (count125 > 0) {
                                int limit125 = (int) Math.min(limit, count125);
                                List<CantonFairBuyer125> list125 = searchBuyer125ByKeywordWithPage(
                                        keyword, productType, offset, limit125, country, hasContact);

                                for (CantonFairBuyer125 buyer : list125) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "126":
                            long count126 = countBuyer126ByKeyword(keyword, productType, country, hasContact);
                            if (count126 > 0) {
                                int limit126 = (int) Math.min(limit, count126);
                                List<CantonFairBuyer126> list126 = searchBuyer126ByKeywordWithPage(
                                        keyword, productType, offset, limit126, country, hasContact);

                                for (CantonFairBuyer126 buyer : list126) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "127":
                            long count127 = countBuyer127ByKeyword(keyword, productType, country, hasContact);
                            if (count127 > 0) {
                                int limit127 = (int) Math.min(limit, count127);
                                List<CantonFairBuyer127> list127 = searchBuyer127ByKeywordWithPage(
                                        keyword, productType, offset, limit127, country, hasContact);

                                for (CantonFairBuyer127 buyer : list127) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "129":
                            long count129 = countBuyer133ByKeyword(keyword, productType, country, hasContact);
                            if (count129 > 0) {
                                int limit129 = (int) Math.min(limit, count129);
                                List<CantonFairBuyer129> list129 = searchBuyer129ByKeywordWithPage(
                                        keyword, productType, offset, limit129, country, hasContact);

                                for (CantonFairBuyer129 buyer : list129) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "130":
                            long count130 = countBuyer133ByKeyword(keyword, productType, country, hasContact);
                            if (count130 > 0) {
                                int limit130 = (int) Math.min(limit, count130);
                                List<CantonFairBuyer130> list130 = searchBuyer130ByKeywordWithPage(
                                        keyword, productType, offset, limit130, country, hasContact);

                                for (CantonFairBuyer130 buyer : list130) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "131":
                            long count131 = countBuyer131ByKeyword(keyword, productType, country, hasContact);
                            if (count131 > 0) {
                                int limit131 = (int) Math.min(limit, count131);
                                List<CantonFairBuyer131> list131 = searchBuyer131ByKeywordWithPage(
                                        keyword, productType, offset, limit131, country, hasContact);

                                for (CantonFairBuyer131 buyer : list131) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "132":
                            long count132 = countBuyer132ByKeyword(keyword, productType, country, hasContact);
                            if (count132 > 0) {
                                int limit132 = (int) Math.min(limit, count132);
                                List<CantonFairBuyer132> list132 = searchBuyer132ByKeywordWithPage(
                                        keyword, productType, offset, limit132, country, hasContact);

                                for (CantonFairBuyer132 buyer : list132) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "133":
                            long count133 = countBuyer133ByKeyword(keyword, productType, country, hasContact);
                            if (count133 > 0) {
                                int limit133 = (int) Math.min(limit, count133);
                                List<CantonFairBuyer133> list133 = searchBuyer133ByKeywordWithPage(
                                        keyword, productType, offset, limit133, country, hasContact);

                                for (CantonFairBuyer133 buyer : list133) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "134":
                            long count134 = countBuyer134ByKeyword(keyword, productType, country, hasContact);
                            if (count134 > 0) {
                                int limit134 = (int) Math.min(limit, count134);
                                List<CantonFairBuyer134> list134 = searchBuyer134ByKeywordWithPage(
                                        keyword, productType, offset, limit134, country, hasContact);

                                for (CantonFairBuyer134 buyer : list134) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "135":
                            long count135 = countBuyer135ByKeyword(keyword, productType, country, hasContact);
                            if (count135 > 0) {
                                int limit135 = (int) Math.min(limit, count135);
                                List<CantonFairBuyer135> list135 = searchBuyer135ByKeywordWithPage(
                                        keyword, productType, offset, limit135, country, hasContact);

                                for (CantonFairBuyer135 buyer : list135) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "136":
                            long count136 = countBuyer136ByKeyword(keyword, productType, country, hasContact);
                            if (count136 > 0) {
                                int limit136 = (int) Math.min(limit, count136);
                                List<CantonFairBuyer136> list136 = searchBuyer136ByKeywordWithPage(
                                        keyword, productType, offset, limit136, country, hasContact);

                                for (CantonFairBuyer136 buyer : list136) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        case "137":
                            long count137 = countBuyer137ByKeyword(keyword, productType, country, hasContact);
                            if (count137 > 0) {
                                int limit137 = (int) Math.min(limit, count137);
                                List<CantonFairBuyer137> list137 = searchBuyer137ByKeywordWithPage(
                                        keyword, productType, offset, limit137, country, hasContact);

                                for (CantonFairBuyer137 buyer : list137) {
                                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                                    baseBuyer.setSessionsNum(session);
                                    result.add(baseBuyer);
                                }
                            }
                            break;
                        default:
                            log.warn("不支持的广交会届数: {}", session);
                            break;
                    }
                }
            } else {
                // 如果没有指定届数，查询所有届数（使用现有的逻辑但不脱敏）
                result = searchAllSessionsForExport(keyword, productType, offset, limit, country, hasContact);
            }

        } catch (Exception e) {
            log.error("导出专用：广交会采购商全字段搜索失败", e);
            throw e;
        }

        log.info("导出专用：搜索完成，返回 {} 条记录", result.size());
        return result;
    }

    /**
     * 导出专用：查询所有届数的数据（不脱敏）
     */
    private List<BaseCantonFairBuyer> searchAllSessionsForExport(String keyword, String productType, int offset, int limit, String country, String hasContact) {
        List<BaseCantonFairBuyer> result = new ArrayList<>();

        try {
            // 获取各届数据的总数
            long count125 = countBuyer125ByKeyword(keyword, productType, country, hasContact);
            long count126 = countBuyer126ByKeyword(keyword, productType, country, hasContact);
            long count127 = countBuyer127ByKeyword(keyword, productType, country, hasContact);
            long count129 = countBuyer129ByKeyword(keyword, productType, country, hasContact);
            long count130 = countBuyer130ByKeyword(keyword, productType, country, hasContact);
            long count131 = countBuyer131ByKeyword(keyword, productType, country, hasContact);
            long count132 = countBuyer132ByKeyword(keyword, productType, country, hasContact);
            long count133 = countBuyer133ByKeyword(keyword, productType, country, hasContact);
            long count134 = countBuyer134ByKeyword(keyword, productType, country, hasContact);
            long count135 = countBuyer135ByKeyword(keyword, productType, country, hasContact);
            long count136 = countBuyer136ByKeyword(keyword, productType, country, hasContact);
            long count137 = countBuyer137ByKeyword(keyword, productType, country, hasContact);

            log.info("导出专用 - 各届数据统计 - 125届: {}, 126届: {}, 127届: {}, 129届：{}，130届：{}，133届：{}， 134届: {}, 135届: {}, 136届: {}, 137届: {}",
                    count125, count126, count127, count129, count130, count133, count134, count135, count136, count137);

            // 计算每个表需要查询的数据量
            int remaining = limit;
            int currentOffset = offset;

            // 查询第125届数据
            if (remaining > 0 && currentOffset < count125) {
                int limit125 = (int) Math.min(remaining, count125 - currentOffset);
                List<CantonFairBuyer125> list125 = searchBuyer125ByKeywordWithPage(
                        keyword, productType, currentOffset, limit125, country, hasContact);

                for (CantonFairBuyer125 buyer : list125) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("125");
                    result.add(baseBuyer);
                }

                remaining -= list125.size();
                currentOffset = 0;
            } else if (currentOffset >= count125) {
                currentOffset -= (int) count125;
            }

            // 查询第126届数据
            if (remaining > 0 && currentOffset < count126) {
                int limit126 = (int) Math.min(remaining, count126 - currentOffset);
                List<CantonFairBuyer126> list126 = searchBuyer126ByKeywordWithPage(
                        keyword, productType, currentOffset, limit126, country, hasContact);

                for (CantonFairBuyer126 buyer : list126) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("126");
                    result.add(baseBuyer);
                }

                remaining -= list126.size();
                currentOffset = 0;
            } else if (currentOffset >= count126) {
                currentOffset -= (int) count126;
            }

            // 查询第127届数据
            if (remaining > 0 && currentOffset < count127) {
                int limit127 = (int) Math.min(remaining, count127 - currentOffset);
                List<CantonFairBuyer127> list127 = searchBuyer127ByKeywordWithPage(
                        keyword, productType, currentOffset, limit127, country, hasContact);

                for (CantonFairBuyer127 buyer : list127) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("127");
                    result.add(baseBuyer);
                }

                remaining -= list127.size();
                currentOffset = 0;
            } else if (currentOffset >= count127) {
                currentOffset -= (int) count127;
            }

            // 查询第129届数据
            if (remaining > 0 && currentOffset < count129) {
                int limit129 = (int) Math.min(remaining, count129 - currentOffset);
                List<CantonFairBuyer129> list129 = searchBuyer129ByKeywordWithPage(
                        keyword, productType, currentOffset, limit129, country, hasContact);

                for (CantonFairBuyer129 buyer : list129) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("129");
                    result.add(baseBuyer);
                }

                remaining -= list129.size();
                currentOffset = 0;
            } else if (currentOffset >= count129) {
                currentOffset -= (int) count129;
            }

            // 查询第130届数据
            if (remaining > 0 && currentOffset < count130) {
                int limit130 = (int) Math.min(remaining, count130 - currentOffset);
                List<CantonFairBuyer130> list130 = searchBuyer130ByKeywordWithPage(
                        keyword, productType, currentOffset, limit130, country, hasContact);

                for (CantonFairBuyer130 buyer : list130) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("130");
                    result.add(baseBuyer);
                }

                remaining -= list130.size();
                currentOffset = 0;
            } else if (currentOffset >= count130) {
                currentOffset -= (int) count130;
            }

            // 查询第131届数据
            if (remaining > 0 && currentOffset < count131) {
                int limit131 = (int) Math.min(remaining, count131 - currentOffset);
                List<CantonFairBuyer131> list131 = searchBuyer131ByKeywordWithPage(
                        keyword, productType, currentOffset, limit131, country, hasContact);

                for (CantonFairBuyer131 buyer : list131) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("131");
                    result.add(baseBuyer);
                }

                remaining -= list131.size();
                currentOffset = 0;
            } else if (currentOffset >= count131) {
                currentOffset -= (int) count131;
            }

            // 查询第132届数据
            if (remaining > 0 && currentOffset < count132) {
                int limit132 = (int) Math.min(remaining, count132 - currentOffset);
                List<CantonFairBuyer132> list132 = searchBuyer132ByKeywordWithPage(
                        keyword, productType, currentOffset, limit132, country, hasContact);

                for (CantonFairBuyer132 buyer : list132) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("132");
                    result.add(baseBuyer);
                }

                remaining -= list132.size();
                currentOffset = 0;
            } else if (currentOffset >= count132) {
                currentOffset -= (int) count132;
            }

            // 查询第133届数据
            if (remaining > 0 && currentOffset < count133) {
                int limit133 = (int) Math.min(remaining, count133 - currentOffset);
                List<CantonFairBuyer133> list133 = searchBuyer133ByKeywordWithPage(
                        keyword, productType, currentOffset, limit133, country, hasContact);

                for (CantonFairBuyer133 buyer : list133) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("133");
                    result.add(baseBuyer);
                }

                remaining -= list133.size();
                currentOffset = 0;
            } else if (currentOffset >= count133) {
                currentOffset -= (int) count133;
            }

            // 查询第134届数据
            if (remaining > 0 && currentOffset < count134) {
                int limit134 = (int) Math.min(remaining, count134 - currentOffset);
                List<CantonFairBuyer134> list134 = searchBuyer134ByKeywordWithPage(
                        keyword, productType, currentOffset, limit134, country, hasContact);

                for (CantonFairBuyer134 buyer : list134) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("134");
                    result.add(baseBuyer);
                }

                remaining -= list134.size();
                currentOffset = 0;
            } else if (currentOffset >= count134) {
                currentOffset -= (int) count134;
            }

            // 查询第135届数据
            if (remaining > 0 && currentOffset < count135) {
                int limit135 = (int) Math.min(remaining, count135 - currentOffset);
                List<CantonFairBuyer135> list135 = searchBuyer135ByKeywordWithPage(
                        keyword, productType, currentOffset, limit135, country, hasContact);

                for (CantonFairBuyer135 buyer : list135) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("135");
                    result.add(baseBuyer);
                }

                remaining -= list135.size();
                currentOffset = 0;
            } else if (currentOffset >= count135) {
                currentOffset -= (int) count135;
            }

            // 查询第136届数据
            if (remaining > 0 && currentOffset < count136) {
                int limit136 = (int) Math.min(remaining, count136 - currentOffset);
                List<CantonFairBuyer136> list136 = searchBuyer136ByKeywordWithPage(
                        keyword, productType, currentOffset, limit136, country, hasContact);

                for (CantonFairBuyer136 buyer : list136) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("136");
                    result.add(baseBuyer);
                }

                remaining -= list136.size();
                currentOffset = 0;
            } else if (currentOffset >= count136) {
                currentOffset -= (int) count136;
            }

            // 查询第137届数据
            if (remaining > 0 && currentOffset < count137) {
                int limit137 = (int) Math.min(remaining, count137 - currentOffset);
                List<CantonFairBuyer137> list137 = searchBuyer137ByKeywordWithPage(
                        keyword, productType, currentOffset, limit137, country, hasContact);

                for (CantonFairBuyer137 buyer : list137) {
                    BaseCantonFairBuyer baseBuyer = convertToBaseBuyerForExport(buyer);
                    baseBuyer.setSessionsNum("137");
                    result.add(baseBuyer);
                }
            }

        } catch (Exception e) {
            log.error("导出专用：查询所有届数数据失败", e);
            throw e;
        }

        return result;
    }

    /**
     * 导出专用：将CantonFairBuyer125转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer125 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第125届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer126转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer126 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第126届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer127转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer127 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第127届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getDemandGoods()); // 使用需求商品作为采购产品类型
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        baseBuyer.getExtendedFields().put("demandInfo", buyer.getDemandInfo());
        baseBuyer.getExtendedFields().put("purchaseList", buyer.getPurchaseList());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());
        // 社交媒体信息
        baseBuyer.getExtendedFields().put("msn", buyer.getMsn());
        baseBuyer.getExtendedFields().put("skype", buyer.getSkype());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer129转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer129 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第129届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer130转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer130 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第130届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer131转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer131 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第131届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer132转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer132 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第132届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer133转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer133 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第133届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }


    /**
     * 导出专用：将CantonFairBuyer134转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer134 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第134届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer135转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer135 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第135届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer136转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer136 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第136届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        // 联系方式相关字段
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail());
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson());

        return baseBuyer;
    }

    /**
     * 导出专用：将CantonFairBuyer137转换为BaseCantonFairBuyer（不脱敏）
     */
    private BaseCantonFairBuyer convertToBaseBuyerForExport(CantonFairBuyer137 buyer) {
        BaseCantonFairBuyer baseBuyer = new BaseCantonFairBuyer();
        baseBuyer.setId(buyer.getId());
        baseBuyer.setCompanyName(buyer.getCompanyName());
        baseBuyer.setCountry(buyer.getCountry());
        baseBuyer.setContactPerson(buyer.getContactPerson());
        // 敏感信息不脱敏
        baseBuyer.setPhone(buyer.getTelephone() != null ? buyer.getTelephone() : buyer.getPhone());
        baseBuyer.setFax(buyer.getFax());
        baseBuyer.setEmail(buyer.getEmail());
        baseBuyer.setWebsite(buyer.getWebsite());
        baseBuyer.setAddress(buyer.getAddress());

        // 设置扩展字段
        baseBuyer.getExtendedFields().put("sessionInfo", "第137届");
        baseBuyer.getExtendedFields().put("countryRegion", buyer.getCountry());
        baseBuyer.getExtendedFields().put("procurementProductType", buyer.getProductCategory());
        baseBuyer.getExtendedFields().put("zipCode", buyer.getZipCode());
        baseBuyer.getExtendedFields().put("companyProfile", buyer.getCompanyProfile());
        // 联系方式相关字段（如果有的话）
        baseBuyer.getExtendedFields().put("contactWay", buyer.getEmail()); // 使用邮箱作为联系方式
        baseBuyer.getExtendedFields().put("contactTeam", buyer.getContactPerson()); // 使用联系人作为联系团队

        return baseBuyer;
    }
}